package com.pinfly.common.crypto.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;

/**
 * Crypto Tool About box
 * 
 * @author kseegmiller
 */
public class CryptoToolAboutBox extends javax.swing.JDialog implements ActionListener
{

    private javax.swing.JButton closeButton;
    private static final String CMD_CLOSE = "close";

    public CryptoToolAboutBox (java.awt.Frame parent)
    {
        super (parent, true);
        initComponents ();
        getRootPane ().setDefaultButton (closeButton);
    }

    public void closeAboutBox ()
    {
        dispose ();
    }

    private void initComponents ()
    {

        closeButton = new javax.swing.JButton ();
        javax.swing.JLabel appTitleLabel = new javax.swing.JLabel ();
        javax.swing.JLabel versionLabel = new javax.swing.JLabel ();
        javax.swing.JLabel appVersionLabel = new javax.swing.JLabel ();
        javax.swing.JLabel appDescLabel = new javax.swing.JLabel ();
        javax.swing.JLabel imageLabel = new javax.swing.JLabel ();

        setDefaultCloseOperation (javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle ("About - Pinfly Crypto Tool");
        setModal (true);
        setResizable (false);

        closeButton.setActionCommand (CMD_CLOSE);
        closeButton.addActionListener (this);
        closeButton.setText ("Close");

        appTitleLabel.setFont (appTitleLabel.getFont ().deriveFont (appTitleLabel.getFont ().getStyle ()
                                                                            | java.awt.Font.BOLD,
                                                                    appTitleLabel.getFont ().getSize () + 4));
        appTitleLabel.setText ("Pinfly Crypto Tool");

        versionLabel.setFont (versionLabel.getFont ().deriveFont (versionLabel.getFont ().getStyle ()
                                                                          | java.awt.Font.BOLD));
        versionLabel.setText ("Product Version:");

        appVersionLabel.setText ("4.0");

        appDescLabel.setText ("A tool for encrypting text utilizing the Pinfly encryption implementation.");

        ImageIcon ico = new ImageIcon ("logo.jpg");
        imageLabel.setIcon (ico);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout (getContentPane ());
        getContentPane ().setLayout (layout);
        layout.setHorizontalGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
                                         .addGroup (layout.createSequentialGroup ()
                                                          .addComponent (imageLabel)
                                                          .addGap (18, 18, 18)
                                                          .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.TRAILING)
                                                                           .addGroup (javax.swing.GroupLayout.Alignment.LEADING,
                                                                                      layout.createSequentialGroup ()
                                                                                            .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                             .addComponent (versionLabel))
                                                                                            .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                            .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                             .addComponent (appVersionLabel)))
                                                                           .addComponent (appTitleLabel,
                                                                                          javax.swing.GroupLayout.Alignment.LEADING)
                                                                           .addComponent (appDescLabel,
                                                                                          javax.swing.GroupLayout.Alignment.LEADING,
                                                                                          javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                          266, Short.MAX_VALUE)
                                                                           .addComponent (closeButton))
                                                          .addContainerGap ()));
        layout.setVerticalGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.LEADING)
                                       .addComponent (imageLabel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                      javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                       .addGroup (layout.createSequentialGroup ()
                                                        .addContainerGap ()
                                                        .addComponent (appTitleLabel)
                                                        .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent (appDescLabel,
                                                                       javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                       javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                       javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.BASELINE)
                                                                         .addComponent (versionLabel)
                                                                         .addComponent (appVersionLabel))
                                                        .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.BASELINE))
                                                        .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup (layout.createParallelGroup (javax.swing.GroupLayout.Alignment.BASELINE))
                                                        .addPreferredGap (javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                          19, Short.MAX_VALUE)
                                                        .addComponent (closeButton).addContainerGap ()));

        pack ();
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    public void actionPerformed (ActionEvent e)
    {
        String cmd = e.getActionCommand ();

        if (CMD_CLOSE.equals (cmd))
        {
            dispose ();
        }

    }

}
